Log rotation is closing a log file and opening a new log file when the first file is considered to be complete. Log rotation is typically performed according to a schedule (e.g., hourly, daily, weekly) or when a log file reaches a certain size.
That’s where the logrotate command in Linux comes into play. logrotate will periodically take the current log files, rename them, optionally compress them, and generate a fresh file to which an application can continue sending its logs.
Log rotation solves these problems by periodically archiving active log files and creating new ones for incoming entries. This process typically involves renaming the current log file (such as by adding a timestamp or number) and then starting a new file